package weixinkeji.dev.dc.base.user.h;

import MyUI.ligerUI.bean.LigerUIOrderBy;
import MyUI.ligerUI.service.LigeruiService;
import weixinkeji.dev.dc.base.user.bean.FWY;
import sys.wx.ann.hm.H;
import sys.wx.ann.hm.M;
import sys.wx.c.ATR;
import sys.wx.c.components.cv.CV;
import sys.wx.m.db.SQL.mysql.common.orderby.OrderBy;
import sys.wx.m.db.SQL.mysql.common.where.Where;
import sys.wx.m.db.SQL.mysql.common.where.WhereConfig;
import sys.wx.m.db.dao.mysql.Dao;
import sys.wx.util.ToolService;
import weixinkeji.dev.dc.base.user.vo.TJ_FWYVO;

@H("weixinkeji/dev/dc/base/user/s")
public class FWYHS {

    ATR a;

    public FWYHS(ATR a) {
        this.a = a;
    }

    @M("/selectAll")//通过 weixinkeji/dev/dc/base/user/s/selectAll.imy 访问
    public String selectAll() {

        LigerUIOrderBy ob = LigeruiService.getOrderBy(a.request);
        String obstr = "";
        if (null != ob.sortname) {
            obstr = OrderBy.getOrderBy(ob.sortname, ob.sortorder);
        }

        //按条件查询查询
        TJ_FWYVO fwyTJ = CV.getObjectByFields(TJ_FWYVO.class, a.request);
        if (null != fwyTJ.andor) {
            a.printOne(LigeruiService.getGRID(Dao.selectVastOrderBy(FWY.class, getVOSelectTJ(fwyTJ), obstr)));
            return null;
        }
        a.printOne(LigeruiService.getGRID(Dao.selectVastOrderBy(FWY.class, obstr)));
        return null;

    }

    private String getVOSelectTJ(TJ_FWYVO vo) {
        WhereConfig wc = new WhereConfig("");
        Where wh = new Where(wc);
        String and_or = vo.andor == 1 ? Where.AND : Where.OR;//1表示 AND; 0表示OR

        wh.put(Where.TJ_IGNORE_EMPTY_NULL, and_or, "fwy_style", "=", vo.fwy_style);

        wh.put(Where.TJ_IGNORE_EMPTY_NULL, and_or, "fwy_name", "LIKE",
                ToolService.IsNullOREmpty(vo.fwy_name)
                ? ""
                : "%" + vo.fwy_name + "%");

        wh.put(Where.TJ_IGNORE_EMPTY_NULL, and_or, "fwy_account", "LIKE",
                ToolService.IsNullOREmpty(vo.fwy_account)
                ? ""
                : "%" + vo.fwy_account + "%");
        
        return wh.getWhereAotuRemove0ANDOR();
    }
}
